package controller;


import entity.Customer;
import entity.Supplier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.CustomerService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/customer")
public class CustomerCon {

    @Resource(name = "customerService")
    private CustomerService customerService;


    @RequestMapping("/ll")
    @ResponseBody
    public List<Customer> listjin(){
        return customerService.listjin();
    }

    @RequestMapping("/Qtiaozhuan")
    public String tiaozhuan(Model model) {
        return "WEB-INF/jsp/xitongshezhi/kehushezhi";
    }
    @RequestMapping("/Qtianjia")
    @ResponseBody
    public List<Customer> add2(Customer customer){
        Customer customer1=new Customer();

        int s=customerService.Qadd(customer);

        return customerService.listjin();

    }
    @RequestMapping("/Qxiugai")
    @ResponseBody
    public List<Customer> Qupd(Customer Customer){
        Customer customer=new Customer();
        int s=customerService.Qupd(customer);
        return  customerService.listjin();
    }
    @RequestMapping("/Qdel")
    @ResponseBody
    public List<Customer> Qdel(Customer customer){
        Customer Customer=new Customer();
        int s=customerService.Qdel(customer);
        return customerService.listjin();

    }

    @RequestMapping("/Qlist")
    @ResponseBody
    public List<Customer> Qlist(String name){
        Customer customer=new Customer();


        customer.setName(name);
        Map<String, Object> mapResult = new HashMap<String, Object>();

        mapResult.put("name",name);
        List<Customer>  customers=customerService.Qlist(mapResult);
        return customers;

    }




}
